﻿using MediatR;
using S.Common.helper;
using S.PurchaseAndSales.Read.Api.Application.Command.SheepSaleCommand;
using S.PurchaseAndSales.Read.Api.Dto;

namespace S.PurchaseAndSales.Read.Api.Application.CommandHandlers.SheepSaleHandler
{
    public class SheepDetailsCommandHandler : IRequestHandler<SheepDetailsCommand, SheepFileDto>
    {
        private readonly IConfiguration configuration;

        public SheepDetailsCommandHandler(IConfiguration configuration) 
        {
            this.configuration = configuration;
        }
        /// <summary>
        /// 通过羊只耳号获取羊只的详情
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<SheepFileDto> Handle(SheepDetailsCommand request, CancellationToken cancellationToken)
        {
            var aa = configuration["GetKongaIp"];
            SheepFileDto sheepFileDto= HttpClientHelper.GetResponse<SheepFileDto>(aa+"/ach/api/SheepFileModel/GetSheepFilesByEarTag?EarTag=" + request.EarTag);
            return sheepFileDto;
        }
    }
}
